#ifndef __VTOR_STEP_MOTOR_H__
#define __VTOR_STEP_MOTOR_H__

#ifdef __cplusplus
extern "C" {
#endif


#include "vtor_elec_module_config.h"

#ifdef __VTOR_STEP_MOTOR__

#define VtorStepMotorState_Forward	1
#define VtorStepMotorState_Stop		0
#define VtorStepMotorState_Reverse	-1

#define VtorPulseMotor_DirPin	0
#define VtorPulseMotor_PulsePin	1

typedef struct VtorStepMotorStruct
{
	int8_t motorIdx;
	int8_t motorEnFlag;
	int8_t motorState;
	int8_t motorPulseLevel; // 脉冲电平
	int32_t motorCurPulse;
	int32_t motorExpPulse;
}VtorStepMotor;

void VtorStepMotor_RotatePulse(VtorStepMotor* motor, int32_t pulse);
void VtorStepMotor_SetPulse(VtorStepMotor* motor, int32_t pulse);
void VtorStepMotor_Stop(VtorStepMotor* motor);

int32_t VtorStepMotor_GetPulse(VtorStepMotor* motor);
uint8_t VtorStepMotor_CheckReady(VtorStepMotor* motor);
void VtorStepMotor_Run(VtorStepMotor* motor);
void VtorPulseMotor_Run(VtorStepMotor* motor);

void VtorStepMotor_WritePinLevel(VtorStepMotor* motor, int8_t pinIdx, uint8_t pinLevel);
void VtorPulseMotor_WritePinLevel(VtorStepMotor* motor, int8_t pinIdx, uint8_t pinLevel);
void VtorStepMotor_Init(void);

#endif // __VTOR_STEP_MOTOR__

#ifdef __cplusplus
}
#endif

#endif /* __VTOR_STEP_MOTOR_H__ */

